import logging
from selenium.webdriver.support.wait import WebDriverWait
from utils import DriverUitls

class BasePage:

    def __init__(self):
        self.driver = DriverUitls.get_driver()


    def find_el(self,location_tuple):
        element = None
        try:
            element = WebDriverWait(DriverUitls.get_driver(),
            10,1).until(lambda x: x.find_element(*location_tuple))
            # print("元素{}定位失败".format(location_tuple))
            logging.info("元素{}定位失败".format(location_tuple))
        except:
            # print("元素{}定位失败".format(location_tuple))
            logging.error("元素{}定位失败".format(location_tuple))
        return element

    def input_text(self,element,input_text):
        try:
            element.clear()
            element.send_keys(input_text)
            # print("输入信息：{},成功".format(input_text))
            logging.info("输入信息：{},成功".format(input_text))
        except:
            # print("输入信息：{},失败".format(input_text))
            logging.info("输入信息：{},失败".format(input_text))